<template>
  <div>
    <el-table
      border
      :data="tableData"
    >
      <el-table-column
        label="序号"
        type="index"
      />
      <el-table-column
        label="标题"
        prop="title"
      />
      <el-table-column
        label="简介"
        prop="description"
      />
      <el-table-column
        label="创建时间"
        prop="date"
      />
      <el-table-column label="更新时间" />
      <el-table-column
        label="热度"
        prop="see"
      />
      <el-table-column
        label="作者"
        prop="author"
      />
      <el-table-column label="操作">
        <template slot-scope="scope">
          <div>
            <el-button
              type="danger"
              @click="del(scope.row._id)"
            >删除</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import * as APIS from '@/api/write'
export default {
  name: 'WriteList',
  data() {
    return {
      tableData: []
    }
  },
  mounted() {
    this.getWriteList()
  },
  methods: {
    getWriteList() {
      APIS.getWriteList({}).then(res => {
        console.log(res, 'res')
        this.tableData = res.data.data
      })
    },
    del(id) {
      APIS.del(id).then(res => {
        this.getWriteList()
      })
    }
  }
}
</script>
